Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft | Addressing name pipe failures on sync and async calls. #1880

Closed
wants to merge 10 commits into from

Conversation

JRahnama
Copy link
Contributor

@JRahnama JRahnama commented Jan 6, 2023

While working on some intermittent failures on test pipelines on, concurrent test runs for retry logic, I noticed there is PipeOptions.Asynchronous in SNINPHandle class ctr. That causes the tests to fail at some random runs. There is an option to pass a variable to decide on sync/async calls, but that approach needs more investigation as the value of async passed down to other functions in TDSParser.Connect for the functionc call _physicalStateObj.CreatePhysicalSNIHandle is set to be alwyas true.

My main concern with this change: what would be the effect of this on async calls that happen after openAsync? will taking out the pipeoptions for asynchronous calls will cause any damage on the async pattern, tasks or threads?

on some other notes:

In the very same class SNINPHandle on the Receive function when the packet length is 0, stream is closed by server, the driver gets the last Win32Exception and throws that as exception. This does not seem like a very good approach to me. There could be some other problem happening in between. For example, There is no process at the other end of the pipe when a wrong password is used. How other drivers have solved this issue?

To repro the issue make sure youa re using named pipes and managed SNI is in use. The test that fails intermittently is:
ConcurrentExecutation in SqlConnectionReliablityTest
cc: @roji, @Wraith2 , @David-Engel , @DavoudEshtehari

@JRahnama JRahnama added the 🐛 Bug! Issues that are bugs in the drivers we maintain. label Jan 6, 2023
@JRahnama JRahnama added this to the 5.1.0 milestone Jan 6, 2023
@codecov
Copy link

codecov bot commented Jan 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ee4ba7e) 70.69% compared to head (dd9e441) 69.97%.
Report is 126 commits behind head on main.

❗ Current head dd9e441 differs from pull request most recent head 71054c0. Consider uploading reports for the commit 71054c0 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1880      +/-   ##
==========================================
- Coverage   70.69%   69.97%   -0.73%     
==========================================
  Files         292      292              
  Lines       61732    61732              
==========================================
- Hits        43643    43197     -446     
- Misses      18089    18535     +446     
Flag Coverage Δ
addons 92.38% <ø> (ø)
netcore 72.95% <100.00%> (-1.13%) ⬇️
netfx 69.14% <ø> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JRahnama
Copy link
Contributor Author

JRahnama commented Jan 9, 2023

while we are at this there is PipeSecurity class which was available in netcoreapp 1.1 and it came back again in net6 and net7. We set ACL in native code, but not in netcore, Discretionary Access Control List (DACL). Something that needs to be brought up.

@lcheunglci lcheunglci removed this from the 5.1.0 milestone Jan 18, 2023
@JRahnama JRahnama changed the title Fix | Addressing name pipe failures on sync and async calls. Draft | Addressing name pipe failures on sync and async calls. Jan 26, 2023
@Wraith2
Copy link
Contributor

Wraith2 commented Jan 27, 2023

There is an option to pass a variable to decide on sync/async calls

This is fairly common and much better than attempting to use a heuristic approach. It can be annoying to write but as long as you're only working within the managed implementation and don't need to change the interface used by native it should just turn out to be code plumbing.

@JRahnama
Copy link
Contributor Author

@Wraith2 so you are pro passing a flag from inside OpenAsync and pass it all the way here? Actually, there is a flag, but mid-way its value is set to be true all the time.

@Wraith2
Copy link
Contributor

Wraith2 commented Jan 27, 2023

It seems like a reasonable approach. It is at least worth trying.

@DavoudEshtehari DavoudEshtehari added this to the 5.2.0-preview3 milestone Jun 5, 2023
@DavoudEshtehari DavoudEshtehari removed this from the 5.2.0-preview4 milestone Oct 31, 2023
@DavoudEshtehari
Copy link
Contributor

Temporary disabled test ConcurrentExecution

- Setup Parameterization so PipeOptions can be configured for Async or WriteThrough
Change to a more precise variable name
Add the setting of the Asynchronous Variable assignment to SqlInternalConnectionTds
@David-Engel
Copy link
Contributor

@JRahnama I think the problem with the test is that it is simply calling async methods in the context of sync methods and we are starving the thread pool. I can repro this locally by increasing the concurrentExecution number. If you SetMinThreads to >= concurrentExecution, the test succeeds. Remember, the default system thread count is # of CPU cores and our test VMs only have 2 cores. Another option is probably to split the test into separate sync and async versions and convert the async one to fully async. But even that option isn't certain with our sync over async issues.

@JRahnama JRahnama closed this May 6, 2024
@JRahnama JRahnama deleted the np-async branch May 6, 2024 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug! Issues that are bugs in the drivers we maintain.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants